<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../lib/vue-2.4.0.js"></script>
</head>
<body>
<div id="app">
    <!--
     watch和computed区别：
     相同点：watch和computed 的属性，都是function
     不同点：computed计算属性的function必须要有返回值
     -->

    <input type="text" v-model="firstname"> +
    <input type="text" v-model="lastname"> =
    <input type="text" v-model="fullname">

    <p>{{ fullname }}</p>

</div>

<script>
    var vm = new Vue({
        el: '#app',
        data: {
            firstname: '',
            lastname: '',
            fullname: '',
        },
        methods: {},
        watch: {
            lastname(newVal,oldVal){

            },
        },
        computed: {
            'fullname': function () {
                console.log('ok')
                return this.firstname + ' - ' + this.lastname
            }
        },
    })
</script>


</body>
</html>
